@use '../src/internal' as *;

/* Accordion */
/* Use with <detail> and <summary> HTML tags */
@if should-generate-classes($ACCORDION) {
    details.accordion {
        border-bottom: 1px solid fill('gray', '300');
        display: block;
        padding: 1rem;

        summary.accordion__summary {
            align-items: center;
            cursor: pointer;
            display: flex;
            font-weight: bold;
            justify-content: space-between;
            list-style-type: none;
            opacity: 0.75;
            transition: all 250ms;

            /* Required for Safari, see https://github.com/Spiderpig86/Cirrus/issues/216 */
            &::-webkit-details-marker {
                display: none;
            }

            &:after {
                background-image: url($img-chevron-dark);
                background-position: right center;
                background-size: 1rem auto;
                background-repeat: no-repeat;
                content: '';
                display: block;
                float: right;
                height: 1rem;
                transform: rotate(-90deg);
                width: 1rem;
            }
        }

        &[open] summary.accordion__summary {
            margin-bottom: 1rem;
            opacity: 1;

            &:after {
                transform: rotate(0);
            }
        }

        &:last-of-type {
            border-color: transparent;
        }
    }
}
